package com.jk;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

//扩展配置功能
@Configuration
public class MyConfigMvc extends WebMvcConfigurerAdapter {

    //所有的WebMvcConfigurerAdapter组件都会一起起作用
    @Bean //将组件注册在容器
    public WebMvcConfigurerAdapter webMvcConfigurerAdapter(){
        WebMvcConfigurerAdapter adapter = new WebMvcConfigurerAdapter() {
            /*视图映射功能*/
            public void addViewControllers(ViewControllerRegistry registry) {
                //视图映射：浏览器发送"/"请求，会来到index页面（thymeleaf解析的页面），
                //配置springboot直接访问静态html页面，不经过controller
                //配置之后，发送/loginAndRegister.html，就相当于在controller中return "loginAndRegister"
                registry.addViewController("/index.html").setViewName("/index");
                registry.addViewController("/index1.html").setViewName("/index1");
                registry.addViewController("/regist.html").setViewName("/regist");
                registry.addViewController("/login1.html").setViewName("/login1");
                registry.addViewController("/login.html").setViewName("login");
                registry.addViewController("/regist_success.html").setViewName("regist_success");
                registry.addViewController("/wei.html").setViewName("/wei");
                registry.addViewController("/product-info.html").setViewName("/product-info");
                registry.addViewController("/shangpin.html").setViewName("/shangpin");
                registry.addViewController("/mycart.html").setViewName("/mycart");
                registry.addViewController("/myorder.html").setViewName("/myorder");
                registry.addViewController("/quanbu.html").setViewName("/quanbu");
                registry.addViewController("/myself.html").setViewName("myself");
                registry.addViewController("/instant-buy.html").setViewName("/instant-buy");
                registry.addViewController("/instant-detail.html").setViewName("/instant-detail");
                registry.addViewController("/mycoupon.html").setViewName("/mycoupon");
                registry.addViewController("/coupon.html").setViewName("/coupon");
                registry.addViewController("/pop.html").setViewName("/pop");
                registry.addViewController("/shop-1.html").setViewName("/shop-1");
                registry.addViewController("/myorderItme.html").setViewName("/myorderItme");

            }
        };
        return adapter;
    }
}